﻿using System.Collections.ObjectModel;
using System.Xml.Serialization;
using PrearrangedChaos.AgileZen.Service.Rest;

namespace PrearrangedChaos.AgileZen.Service.Model
{
    /// <remarks/>
    [XmlType(AnonymousType = true)]
    [XmlRoot(ElementName = "role", Namespace = "", IsNullable = false)]
    [ZenRestRequest("projects/{ProjectId}/roles/{RoleId}", "projects/{ProjectId}/roles")]
    public partial class Role : RoleUpdater, IRole
    {
        private IUser[] _members;

        [XmlArrayItemAttribute("user", IsNullable = false)]
        [XmlArray(ElementName = "members")]
        public User[] MembersXmlElement
        {
            get { return _members as User[]; }
            set { _members = value; }
        }

        public bool MembersXmlElementSpecified { get { return false; } }

        [XmlIgnore]
        public ReadOnlyCollection<IUser> Members
        {
            get { return new ReadOnlyCollection<IUser>(_members ?? new User[0]); }
        }

        [XmlIgnore]
        public new ApiAccess Access
        {
            get { return base.Access == null ? default(ApiAccess) : base.Access.Value; }
            set { base.Access = value; }
        }
    }
}